/**
 * 消息记录管理初始化
 */
var VpnEditPushMsg = {
    form: null
};


VpnEditPushMsg.initForm = function(){
    layui.use('form', function(){
        var form = layui.form;
        VpnEditPushMsg.form = form;
        var loading;

        //监听提交
        form.on('submit(formPushMsg)', function(data){
            layer.confirm("是否想要立即推送信息",function (index) {
                layer.close(index);
                loading = layer.load(0,{
                    shade:false,
                    time: 30 * 1000
                });
                setTimeout(function () {
                    var ajax = new $ax(Feng.ctxPath + "/vpnPushMsg/addPushMsg", function (data) {
                        Feng.success("推送成功!");
                        layer.close(loading);
                        VpnEditPushMsg.clearForm();
                    }, function (data) {
                        Feng.error(data.responseJSON.message + "!");
                        layer.close(loading);
                    });
                    ajax.set(data.field);
                    ajax.start();
                })
            });
            return false;
        });

        form.on("select(actionFlag)",function (data) {
            console.log(data.value);
            if (data.value == 3){
                $("#boxLink").show();
            }else{
                $("#boxLink").hide();
                $("#linkUrl").val("");
            }
        });
    });
}


VpnEditPushMsg.clearForm = function(){
    $("#pushForm")[0].reset();
};

$(function () {
    VpnEditPushMsg.initForm();
});
